import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 找出列表中任意两个时间的最小时间差的分钟数
     * @param timePoints string字符串ArrayList 时间列表
     * @return int整型
     */
    public int findMinDifference (ArrayList<String> timePoints) {
        // write code here
        List<Integer> list = new ArrayList<>();

        for (String time : timePoints) {
            list.add(getMinutes(time));
        }

        Collections.sort(list);

        int minm = Integer.MAX_VALUE;

        for(int i = 1; i < list.size(); i++) {
            minm = Math.min(minm, Math.min(list.get(i) - list.get(i - 1), 24 * 60 - list.get(i) + list.get(i - 1)));
        }

        return minm;
    }

    public int getMinutes (String time) {
        int mins;

        String[] arrs = time.split(":");
        int hour = Integer.valueOf(arrs[0]);
        int min = Integer.valueOf(arrs[1]);

        mins = hour * 60 + min;

        return mins;
    }
}